package com.xci.sys.entity;

import cn.afterturn.easypoi.excel.annotation.Excel;
import cn.afterturn.easypoi.excel.annotation.ExcelIgnore;
import com.xci.core.domain.BaseOperateUserEntity;
import com.xci.core.internal.Const;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;

/**
 * 系统历史日志
 */
@Data
@EqualsAndHashCode(callSuper = true)
@ApiModel(description = "系统历史日志")
public class SysHistoryLog extends BaseOperateUserEntity {
    /**
     * 历史日志主键
     */
    @ExcelIgnore @Excel(name = "历史日志主键")
    @ApiModelProperty(value = "历史日志主键", required = true, position = 1)
    private String id;

    /**
     * 操作类型 [新增_1,修改_2,删除_3]
     */
    @NotNull(message = "操作类型不能为空")
    @Excel(name = "操作类型")
    @ApiModelProperty(value = "操作类型 [新增_1,修改_2,删除_3]", required = true, position = 2)
    private Integer category;

    /**
     * 操作类型名称
     */
    @ApiModelProperty(value = "操作类型文本", required = true, position = 3)
    public String getCategoryText() {
        //操作类型 [新增_1,修改_2,删除_3]
        switch(category) {
            case 1:
                return "新增";
            case 2:
                return "修改";
            case 3:
                return "删除";
        }
        return Const.EMPTY;
    }

    /**
     * 表名
     */
    @NotBlank(message = "表名不能为空")
    @Length(max = 100, message = "表名不能超过{max}个字符")
    @Excel(name = "表名")
    @ApiModelProperty(value = "表名", required = true, position = 4)
    private String tableName;

    /**
     * 主键值
     */
    @NotNull(message = "主键值不能为空")
    @Excel(name = "主键值")
    @ApiModelProperty(value = "主键值", required = true, position = 5)
    private String primaryKey;

    /**
     * 操作前数据
     */
    @Excel(name = "操作前数据")
    @ApiModelProperty(value = "操作前数据", position = 6)
    private String beforeData;

    /**
     * 操作后数据
     */
    @Excel(name = "操作后数据")
    @ApiModelProperty(value = "操作后数据", position = 7)
    private String afterData;

    /**
     * 备注
     */
    @Excel(name = "备注")
    @ApiModelProperty(value = "备注", position = 8)
    private String remark;
}